﻿<style>
    .fixed .column-danhba{
        width: 15%;
    }
    .success {font-weight: bold;color: green; text-align: center;}
	#huy-sua{
		display: none;
	}
	.deleted-row
	{
		background: red;
		margin-left: 10px;
		color: yellow;
	}
</style>
<script>
	function sua(idSua){	
		var id = idSua.substring(4);
		document.getElementById("hanhdong").value="sua";
		document.getElementById("idSua").value=id;
		document.getElementById("submit-add").value="Sửa danh bạ";
		document.getElementById("huy-sua").style.display="inline";
		var thongtin = document.getElementById("info-"+id);
		document.getElementById("input-hoten").value=thongtin.getElementsByTagName("td")[0].getElementsByTagName("a")[0].innerText;
		document.getElementById("input-sdt").value=thongtin.getElementsByTagName("td")[1].getElementsByTagName("a")[0].innerText;
		document.getElementById("input-email").value=thongtin.getElementsByTagName("td")[2].getElementsByTagName("a")[0].innerText;
		//document.getElementById("input-ngaysinh").value=(new Date(thongtin.getElementsByTagName("td")[3].getElementsByTagName("a")[0].innerText)).toLocaleDateString("en-US");
		document.getElementById("input-diachi").value=thongtin.getElementsByTagName("td")[4].getElementsByTagName("a")[0].innerText;
	}
	function huySua(){
		document.getElementById("hanhdong").value="them";		
		document.getElementById("submit-add").value="Thêm danh bạ";
		document.getElementById("huy-sua").style.display="none";
        document.getElementById("input-hoten").value="";
        document.getElementById("input-sdt").value="";
        document.getElementById("input-email").value="";
        document.getElementById("input-diachi").value="";
	}
	function xoa(idXoa)
	{
		var id = idXoa.substring(4);
		var xmlhttp=new XMLHttpRequest();
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
			 document.getElementById("info-" + id).innerHTML = '<th scope="row" class="check-column"></th><td class="post-title page-title column-title"><strong><a class="deleted-row">Đã xóa</a></strong></td>';
			}
		  }
		xmlhttp.open("GET", "<?php echo plugins_url(); ?>/quanlydanhba/qldb_action.php?xoa="+id,true);
		xmlhttp.send();
	}
</script>